#include "test.h"

/* test modules */
#include "frame_spec_test.h"
#include "frame_test.h"
#include "frame_depot_test.h"
#include "link_test.h"
#include "frame_link_test.h"
#include "pass_op_test.h"
#include "graph_test.h"
#include "pca_test.h"

#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

static void run_test(Test* test);
static void delete_test(Test* test);

int main(int argc, const char* argv[]) {
	
	set<Test*> tests;
	
	tests.insert(new FrameSpecTest());
	tests.insert(new FrameTest());
	tests.insert(new FrameDepotTest());
	tests.insert(new LinkTest());
	tests.insert(new FrameLinkTest());
	tests.insert(new PassOpTest());
	tests.insert(new GraphTest()); 
	tests.insert(new PcaTest());
	for_each(tests.begin(), tests.end(), run_test);
	for_each(tests.begin(), tests.end(), delete_test);

	return 0;
}

void run_test(Test* test) {
	if (test != NULL) {
		bool success = test->run();
		cout << test->description() << ": ";
		if (success) {
			cout << "pass";
		}
		else {
			cout << "fail";
		}
		cout << endl;
	}
}

void delete_test(Test* test) {
	delete test;
}